﻿@model QuanLyGiaoVuUI.Models.TaiLieu.ChonTaiLieuViewModel

@{
    Layout = null;
}
<script src="@Url.Content("~/Content/js/jsTree/jquery.jstree.js")"></script>
<link href="~/Content/css/jsTree/themes/default/style.css" rel="stylesheet" />

<input type="hidden" name="selectedId" id="selectedId" value="" />
<div class="grid_2">
    <div id="folderTree"></div>
</div>
<div class="grid_10" style="width: 70%">
    <div id="folderContent"></div>
</div>

<script>
        $(document).ready(function () {
            $("#thuMucDuocChon").val("");

            $("#folderTree").jstree({
                "plugins": ["themes", "json_data", "ui"],
                "json_data": {
                    "ajax": {
                        "url": "/TaiLieuGiangVien/GetThuMuc",
                        "data": function (n) {
                            return {
                                "maThuMucCha": n.attr ? n.attr("id") : null
                            };
                        }
                    }
                }
            });
            $("#folderTree").bind("select_node.jstree", function (NODE, REF_NODE) {
                var a = $.jstree._focused().get_selected();
                $("#thuMucDuocChon").val(a.attr("id"));
                if ($("#folderContent")) {
                    $("#folderContent").load("/TaiLieu/ChonTaiLieuGrid?thuMucHienTai=" + a.attr("id"));
                }
            });
        });

        var ChonTaiLieuDialog = new function () {
            this.MaTaiLieu = null;
            this.TenTaiLieu = null;
            this.SetTaiLieu = function (maTaiLieu,tenTaiLieu) {
                this.MaTaiLieu = maTaiLieu;
                this.TenTaiLieu = tenTaiLieu;
            }
        }
</script>